<?php

namespace app\controller\api;

use app\exception\ErrnoPlus;
use app\service\NotesInfoService;
use app\validate\NotesInfoValidate;
use share\controller\ApiBaseController;
use share\exception\ApiException;
use share\service\ContextService;
use share\utils\Helper;

class NotesInfoController extends ApiBaseController{

    /**
     * @description: 
     * @return {*}
     * @use: 
     */
    public function initValidate(){
        $this->validate = new NotesInfoValidate();
    }

    /**
     * 新增
     */
    public function add_action(){
        $scene = empty($this->request->param('contactType')) ? 'add' : 'addV2';
        $input = $this->check($scene);
        if(isset($input['notes'])){
            $input['notes'] = Helper::filterEmoji($input['notes']);
        }
        // if(!Helper::hasEmoji($input['notes'])){
        //     throw new ApiException("notes data not support emoji",ErrnoPlus::COMMON_ERROR);
        // } 
        $vendor = ContextService::getVendor();
        $appVersion = ContextService::getAppVersion();       
        return self::ok(NotesInfoService::addNotes($input,$vendor,$appVersion));
    }
}